package com.mxpio.erp.common.quality.entity;

import com.mxpio.erp.common.jpa.model.NoticeLine;
import com.mxpio.erp.common.jpa.model.QualityOrder;
import com.mxpio.erp.common.vo.OrderExcuteLineVo;
import com.mxpio.erp.common.workshop.entity.ManufactureOrder;
import com.mxpioframework.security.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_WORKSHOP_IN_QO")
@Schema(description="生产入库验收单")
public class MoInQualityOrder extends QualityOrder {

	private static final long serialVersionUID = 1L;

	@Column(name = "ORDER_TYPE_")
	@Schema(description = "单据类型")//01 普通，02 计划，03 返工
	@Dict(dicCode="ERP_MO_ORDER_TYPE")
	private String orderType;
	@Transient
	private List<MoInQualityOrderLine> moInQualityOrderLines;
	@Transient
	private ManufactureOrder order;
	@Override
	public List<? extends NoticeLine> getNoticeLines() {
		return this.moInQualityOrderLines;
	}

	@Override
	public String initTypeCode() {
		return "Q01";
	}

	@Override
	public NoticeLine createLine(OrderExcuteLineVo orderExcuteVo) {
		NoticeLine noticeLine = new MoInQualityOrderLine();
		noticeLine.setOriginBizLineNo(orderExcuteVo.getBizOrderlineNo());
		noticeLine.setOriginBizNo(orderExcuteVo.getBizOrderNo());
		noticeLine.setItemCode(orderExcuteVo.getItemCode());
		noticeLine.setNoticeNo(this.getNoticeNo());
		noticeLine.setQuantity(orderExcuteVo.getQuantity());
		noticeLine.setSort(orderExcuteVo.getSort());
		noticeLine.setLotNo(orderExcuteVo.getLotNo());
		noticeLine.setSubLotIndex(orderExcuteVo.getSubLotIndex());
		return noticeLine;
	}

}
